#ifndef _GATEWAY_TASKPOOL_H_
#define _GATEWAY_TASKPOOL_H_

#include "gateway_task.h"
#include <boost/threadpool.hpp>

class gateway_taskpool
{
private:
	 gateway_taskpool();

public:
	/**
	*	@线程安全的单件构造方式
	*/
	static gateway_taskpool* get_instance();

	//默认线程池大小为cpu*2
	bool start();
	bool stop();

	void cancel();
	bool adjust(unsigned int thread_size);
	bool schedule(gateway_task_ptr task, void* param);
private:
	unsigned int _thread_count;
	boost::threadpool::pool _threadpool;

	static boost::uint32_t _lock_state;
	static gateway_taskpool* _task_pool;
};


#endif